package com.whl.basic.config;

import com.whl.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登陆拦截的配置类
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                // 放行到登录页面的请求
                .excludePathPatterns("/login/**")
                // 放行用户注册
                .excludePathPatterns("/user/register/**")
                // 放行店铺入驻
                .excludePathPatterns("/shop/settlement","/shop/active/**")
                // 放行文件上传接口
                .excludePathPatterns("/fastDfs/**")
                // 放行验证码的接口
                .excludePathPatterns("/verifyCode/**")
                // 放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
                // 放行店铺入驻
    }
}
